home *** CD-ROM | disk | FTP | other *** search
/ EnigmA Amiga Run 1996 June / EnigmA AMIGA RUN 08 (1996)(G.R. Edizioni)(IT)[!][issue 1996-06][EARSAN CD VII].iso / earcd / utilmus / octv5tt4.lha / Docs / ARexx&OctaMED.txt.pp / ARexx&OctaMED.txt
Text File  |  1980-01-01  |  8KB  |  182 lines

  1.  
  2.  
  3.                                                            
  4.                                                            
  5.                                ARexx and OctaMED           
  6.                                                            
  7.                                                            
  8.                         An exploration of multi-tasking    
  9.                           For multimedia applications      
  10.                                                            
  11.                                                            
  12.  
  13.  
  14.              An Article written for RBF Software by Gareth R.Craft
  15.  
  16.  
  17.  
  18.  
  19. In 1991, the Amiga won  the  'European  Home  Computer  of the Year' award. Its
  20. supeior Graphic users  Interface,  multi-tasking,  and  impressive  graphic and
  21. sound abilities have brought a new level of computing power to the 'home' user.
  22. Now, one thing that everybody expects from any personal computer is the ability
  23. to offer control and automation over  all  its  tasks.  This was true even when
  24. home computers were paltry affairs by  today's  standards. As users become less
  25. dazzled by the abilities of the machine,  they become more intrested in how to
  26. use it practically themselves. This shift  from  passive to a more active style
  27. of home computing stresses the need for a personal programming language for the
  28. Amiga.
  29.  
  30. The lay person could well be excused  for  thinking that such a language should
  31. come automatically with the computer.  In an  ideal world that may be the case,
  32. but in reality, good software always  takes  time  to follow the hardware.  For
  33. many reasons, neither AmigaBASIC nor AmigaODS  ever became popular for personal
  34. programming.  A substantial vacuum existed  in  this  area.  That was until the
  35. long awaited release of  Workbench  2.0  on  the  Amiga  which introduced a new
  36. contender in the personal programming lamguage stakes - Arexx.
  37.  
  38. ARexx is derived from the REXX  language  used  on the big computers for script
  39. control and interprocess communication.   It  was  implemented  on the Amiga by
  40. Bill Hawes, a programmer with  some  impressive  programs  to  his name.  It is
  41. generally agreed that the implementation is  extremely sound, and that it takes
  42. special advantage of the Amiga's features.   ARexx  is  not a new language, and
  43. has had something of a cult  following  for  quite a while, especially among US
  44. programmers.  However,  once  its  super-practical  nature  started  to  become
  45. apparent,  more  and  more  people  became  interested.   Today,  many  serious
  46. applications have ARexx support and Teijo  Kinunen's  OctaMED is a good example
  47. where multi-tasking and  multi-media  follow  this  new  ARexx tradition.  What
  48. follows is a discussion of  some  of  the  ARexx  Commands and writing an ARexx
  49. script for the OctaMEDPlayer and multi-tasking.
  50.  
  51. The ARexx ADDRESS instruction, which has  a number of forms including  'address
  52. COMMAND' is the method  used  to  communicate  with  the underlying AmigaDOS by
  53. setting up an ARexx host address.
  54.  
  55. e.g.
  56.  
  57. If we have OctaMEDPlayer in df0: we can  use  ARexx to ask AmigaDOS to load and
  58. run the program.
  59.  
  60.  
  61.         /* Music Example.rexx */
  62.           address command ' run df0:OCTAMEDPLAYER'
  63.           say 'loading OCTAMEDPLAYER Program'
  64.  
  65.  
  66. Now  in  order  to  send  some   messages   from  ARexx  to  our  host  address
  67. OctaMEdPlayer, this port must actually  exist,  and  due  to the time taken for
  68. AmigaDOS to load and run a  program  it  is  necessary  to instruct ARexx via a
  69. script to wait until this program has started.
  70.  
  71. The ARexx 'WaitForPort' instruction is used  for  this purpose, asking ARexx to
  72. run  the  WaitForPort  utility  and  wait  for  OctaMEDPlayer  to  set  up  its
  73. communication port...
  74.  
  75.  
  76.            address command 'WaitForPort
  77.            OCTAMEDPLAYER
  78.  
  79. Once the port is found and the  ARexx  script  reawakens, it is possible to set
  80. ARexx's current host address to OCTAMEDPLAYER  using  the following form of the
  81. ADDRESS instruction...
  82.  
  83.  
  84.         address 'OCTAMEDPLAYER'
  85.         /* Speak to Player' */
  86.  
  87.  
  88. We could for example create an ARexx script to  load up a module, play it for a
  89. while, stop  it,  diplay  some  kind  of  closing  down  message  and  the quit
  90. OctaMeDPlayer.
  91.  
  92.  
  93.         /* Music Example 1.rexx */
  94.         address command 'run df0:OctaMEDPlayer'
  95.         say 'loading OctaMEDPlayer program'
  96.         address command 'WaitForPort'
  97.         OCTAMEDPLAYER
  98.         address 'OCTAMEDPLAYER          /* Speak to the Player */
  99.         'Loadmod df0:mysong'            /* load specified song */
  100.         'Play'                          /* Start Playing */
  101.         Call Delay (20 * 50)            /* Play for 20 Seconds */
  102.         'Stop'                          /* Stop Playing */
  103.         Say 'Closing down OctaMEDPlayer Program'
  104.         'quit'                          /* Shut Down PLayer */
  105.  
  106.  
  107. Note:-
  108.  
  109. LOADMOD,  PLAY,  STOP  and  QUIT  are  not  ARexx  commands  but  are  in  fact
  110. instructions implemented by  the  programmer  in  the  OctaMEDPlayer interface.
  111. Since the above script contains the ARexx  delay() function, it is necessary to
  112. install the "rexxsupport.library" before it is run. Typing in the at the prompt
  113. in the AmigaDOS Shell:-
  114.  
  115.         RXLIB rexxsupport.library 0 -30 0
  116.  
  117.         will preload it for us.
  118.  
  119.  
  120. Alternatively we can ammend the  script  to  check  for and install the library
  121. accordingly.
  122.  
  123.         /* Music Example 2.rexx' */
  124.         If ~Show('L','rexxsupport.library')
  125.         then do
  126.         Say 'adding rexxsupport library'
  127.         Call AddLib('rexxsupport.library',0,30,0)
  128.           end
  129.         address Command 'run df0:OctaMedPlayer'
  130.         Say 'Loading OctaMEDPLayer Program'
  131.         address command 'WaitForPort OCTAMEDPLAYER'
  132.         address 'OCTAMEDPLAYER'         /* Talk to the Player */
  133.         'loadmod df0:mysong'            /* Load the specified song */
  134.         'Play'                          /* Start Playing */
  135.         Call delay (20 * 50)            /* Play for 20 seconds */
  136.         'Stop'                          /* Stop Playing */
  137.         say 'Closing down OctaMEDPlayer Program'
  138.         'quit'                          /*Shut down the Player */
  139.  
  140.  
  141. ARexx scripts normally tend to do more  difficult  jobs and so need rather more
  142. error checking code.  What is  not  apparent  in  this  example is in fact that
  143. often the result of the ARexx  involvement  will  be that the combined power of
  144. the various parts of an  application  is  actually greater thean the individual
  145. components.  With a little modification  our  example  script  could be made to
  146. control the OctaMEDPlayer at the sametime  as controlled an IFF picture display
  147. generated by another ARexx controllable program -  the net result then would be
  148. an integrated sound/visual multimedia  type  presentation  that neither program
  149. could have acheived on its own.
  150.  
  151.  
  152. Gareth R.Craft.
  153.  
  154.  
  155.                                 Further Reading
  156.                                 ---------------
  157.  
  158.                         ARexx Programming on the Amiga
  159.                                 by Chris Zamara
  160.                               Published by Abacus
  161.                                    Price £30
  162.  
  163.                            Using ARexx on the Amiga
  164.                             Published by DTBS Books
  165.                                  Price £29.95
  166.  
  167.            The ARexx Language: The Practice Approach to Programming
  168.                                By M.F. Conlishan
  169.                             ISBN No. 1-3-7806521-1
  170.                                    Price £40
  171.  
  172.  
  173.                                 Gareth R.Craft
  174.                                  12 Mount Road
  175.                                     Halton
  176.                                     Runcorn
  177.                               Cheshire. WA7 2BH.
  178.                                  England. U.K.
  179.  
  180.                              Tel: +44 0928 563762
  181.  
  182.